# 最小支持的 CMake 版本
cmake_minimum_required(VERSION 3.10)

# 设置项目名称
project(media_pusher)

# 设置 C++ 标准
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 查找 log 库（Android 日志库）
find_library(log-lib log)

############################### 以下所有库均基于Android 8（API 26）编译 ###############################

# 添加 eXosip2、osip2 和 osipparser2 的共享库
add_library(libexosip2 SHARED IMPORTED)
set_target_properties(libexosip2 PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libeXosip2.so)

add_library(libosip2 SHARED IMPORTED)
set_target_properties(libosip2 PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libosip2.so)

add_library(libosipparser2 SHARED IMPORTED)
set_target_properties(libosipparser2 PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libosipparser2.so)

# 添加本地 C++ 源码文件
add_library(media_pusher SHARED
        media_pusher.cpp
        pugixml.cpp
        xml_builder.cpp
        sdp_parser.cpp
        sip_register.cpp
        rtp_sender.cpp
)

# 包含头文件路径
target_include_directories(media_pusher PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

# 链接库
target_link_libraries(media_pusher
        ${log-lib}
        libexosip2
        libosip2
        libosipparser2
)